/*
 * SelfComputeThermalExpansionEigenStrain.C
 *
 *  Created on: 2018年1月9日
 *      Author: liuxiao
 */

#include "SelfComputeThermalExpansionEigenStrain.h"
registerMooseObject("RoshanApp", SelfComputeThermalExpansionEigenStrain);
#pragma once
template<>
InputParameters validParams<SelfComputeThermalExpansionEigenStrain>()
{
  InputParameters params = validParams<ComputeThermalExpansionEigenstrainBase>();
  params.addClassDescription("Computes Eigenstrain due to thermal expansion");
  params.addCoupledVar("temperature", 273, "Coupled temperature in units of Kelvin");
  params.addParam<std::vector<Real>>("thermal_expansion_coeff_list","Thermal expansion coefficient in 1/K");
  params.addParam<std::vector<Real>>("thermal_expansion_coeff_T_list","Thermal expansion coefficient in 1/K");
  return params;
}

SelfComputeThermalExpansionEigenStrain::SelfComputeThermalExpansionEigenStrain(const InputParameters & parameters) :
		ComputeThermalExpansionEigenstrainBase(parameters),
    _temperature(coupledValue("temperature")),
	_thermal_expansion_coeff_list(getParam<std::vector<Real>>("thermal_expansion_coeff_list")),
	_thermal_expansion_coeff_T_list(getParam<std::vector<Real>>("thermal_expansion_coeff_T_list")),
	_thermal_expansion_coeff(declareProperty<Real>("thermal_expansion_coeff"))
{
	_thermal_expansion_coeff_T= LinearInterpolation(_thermal_expansion_coeff_T_list, _thermal_expansion_coeff_list);
}

void
SelfComputeThermalExpansionEigenStrain::computeThermalStrain(Real & thermal_strain,
        Real & instantaneous_cte)
{

	  _thermal_expansion_coeff[_qp]=_thermal_expansion_coeff_T.sample(_temperature[_qp]);
	  thermal_strain = _thermal_expansion_coeff [_qp]* (_temperature[_qp] - _stress_free_temperature[_qp]);
	  instantaneous_cte = _thermal_expansion_coeff[_qp];
}



